﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CNotebook;
using CNotebook.Inventory;

namespace NotebookS2.Inventory.Logs
{
    public partial class LOGS_IGN : Form
    {
        public LOGS_IGN()
        {
            InitializeComponent();
        }

        public string ConnectionString { get; set; }

        public void PrintPreview()
        {
            if (xtraTabControl1.SelectedTabPageIndex == 0)
            {
                gridControlDocument.ShowPrintPreview();
            }
            else
            {
                gridControlItems.ShowPrintPreview();
            }
        }

        private void btnRetreiveDocuments_Click(object sender, EventArgs e)
        {
            ReceiptManager oManager = new ReceiptManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            DataTable dt = oManager.GetTransactionLogPerDocument(Convert.ToDateTime(dtFromDocuments.EditValue), Convert.ToDateTime(dtTODocuments.EditValue));

            oManager.Close();

            gridControlDocument.DataSource = dt;
            gridControlDocument.Refresh();
        }

        private void btnPreviewItems_Click(object sender, EventArgs e)
        {

            ReceiptManager oManager = new ReceiptManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            DataTable dt = oManager.GetTransactionLogPerItem(Convert.ToDateTime(dtFROMItems.EditValue), Convert.ToDateTime(dtTOItems.EditValue));

            oManager.Close();

            gridControlItems.DataSource = dt;
            gridControlItems.Refresh();
        }

        private void LOGS_IGN_Load(object sender, EventArgs e)
        {
            dtFromDocuments.EditValue = System.DateTime.Now;
            dtTODocuments.EditValue = System.DateTime.Now;
            
            dtFROMItems.EditValue = System.DateTime.Now;
            dtTOItems.EditValue = System.DateTime.Now;
        }
    }
}
